﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace Imgur.Net.Auth
{
    /// <summary>
    /// Thrown when Imgur returns an error on an attempt to refresh a token. This generally indicates
    /// that the refresh token used was bad.
    /// </summary>
    [Serializable]
    public class RefreshTokenInvalidException : Exception
    {
        public RefreshTokenInvalidException()
        {
        }

        public RefreshTokenInvalidException(string message) : base(message)
        {
        }

        public RefreshTokenInvalidException(string message, Exception innerException) : base(message, innerException)
        {
        }

        protected RefreshTokenInvalidException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
        }

        protected bool Equals(RefreshTokenInvalidException other)
        {
            return string.Equals(Message, other.Message) && Equals(InnerException, other.InnerException);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Equals((RefreshTokenInvalidException) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return ((Message != null ? Message.GetHashCode() : 0)*397) ^ (InnerException != null ? InnerException.GetHashCode() : 0);
            }
        }

        public static bool operator ==(RefreshTokenInvalidException left, RefreshTokenInvalidException right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(RefreshTokenInvalidException left, RefreshTokenInvalidException right)
        {
            return !Equals(left, right);
        }
    }
}
